package com.sjh.baseui.helper

import android.content.Context
import android.util.TypedValue
import net.lucode.hackware.magicindicator.buildins.ArgbEvaluatorHolder
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView
/**
 *指示器 字体大小的改变
 * @author ysj
 * @date 2020/8/14 16:19
 */
class InformationPagerTitleView(context: Context) : SimplePagerTitleView(context) {
    var mSelectSize = 16
    var mNormalSize =15
    override fun onLeave(index: Int, totalCount: Int, leavePercent: Float, leftToRight: Boolean) {
        setTextColor(ArgbEvaluatorHolder.eval(leavePercent, mSelectedColor, mNormalColor))
        setTextSize(TypedValue.COMPLEX_UNIT_DIP,mSelectSize - (mSelectSize - mNormalSize)*leavePercent)
    }

    override fun onEnter(index: Int, totalCount: Int, enterPercent: Float, leftToRight: Boolean) {
        setTextColor(ArgbEvaluatorHolder.eval(enterPercent, mNormalColor, mSelectedColor))
        setTextSize(TypedValue.COMPLEX_UNIT_DIP, mNormalSize + (mSelectSize - mNormalSize)*enterPercent)
    }

    override fun onSelected(index: Int, totalCount: Int) {
        super.onSelected(index, totalCount)
        paint.isFakeBoldText = true
    }

    override fun onDeselected(index: Int, totalCount: Int) {
        super.onDeselected(index, totalCount)
        paint.isFakeBoldText = false
    }
}